{extend name="public/base" /}

<!--尾部-->

<!--返回顶部-->
{block name="content"}
{__block__}
<input type="hidden" name="mun_url" id="mun_url" value="2,1"/>
<script src="../../static/uedi/ueditor.config.js" type="text/javascript" charset="utf-8"></script>
<script src="../../static/uedi/ueditor.all.js" type="text/javascript" charset="utf-8"></script>
<div class="c-r right">
	<div class="label1">
		<div class="title">
			信息管理
		</div>

		<div class="label-4">
			<div class="form" id="forms">
				<div class="breadcrumb">
					<span>
						<a href="#">信息管理 </a>
						<span class="separator">/</span>
					</span>
					<span>
						<span>新增信息</span>
					</span>
				</div>

				<form action="insert" method="post" enctype="multipart/form-data" class="form-2">
					<div><label class="ltxt">分类:</label>
						<div class="bor bor2 bor4">
							<span>请选择</span><i></i>
							<ul style="display: none;z-index: 9999;">
								{foreach name="menus" item="vo"}
								<li data-type = "{$vo.tid}">{$vo.name}</li>
								{/foreach}
							</ul>
						</div>
						<div class="bor bor6 bor0" >
							<span>请选择</span><i></i>
							<ul style="display: none;z-index: 9999;">
							</ul>
						</div>
						<div class="bor bor7 bor0">
							<span>请选择</span><i></i>
							<ul style="display: none;z-index: 9999;">
							</ul>
						</div>
						<span></span>
					</div>					
					<div>
						<label class="ltxt">信息名称:</label><input type="text" name="name" id="" value="" />
						<span></span>
					</div>
					<div><label class="ltxt">内容:</label>
			
					    <!-- 加载编辑器的容器 -->
					    <script id="container" name="content" type="text/plain">
					    </script>
					    <!-- 配置文件 -->
					    <script type="text/javascript" src="ueditor.config.js"></script>
					    <!-- 编辑器源码文件 -->
					    <script type="text/javascript" src="ueditor.all.js"></script>
					    <!-- 实例化编辑器 -->
					    <script type="text/javascript">
					        var ue = UE.getEditor('container');
					    </script>
					</div>


					<div><label></label><button class="btns btn-right subbtn">完成</button><button class="btns btn-right">返回</button></div>
					<div class="clear"></div>
					<input type="hidden" name="datatype_one" id="datatype_one" value="" />
					<input type="hidden" name="datatype_two" id="datatype_two" value="" />
					<input type="hidden" name="menu" id="menu" value="" />
					<input type="hidden" name="caidan" id="caidan" value="" />
					<input type="hidden" name="imgurl" id="imgurl" value="" />
				</form>
			</div>

		</div>

	</div>
</div>
<div id="toup">
	<img src="../../static/home/img/toup.png"/>
</div>
<div id="wrap" class="wrap">
	<div class="wrap-body express">
		<div class="title">
			运费计算规则
		</div>
		<div class="wrap-con">
			<img src="../../static/home/img/e825205360d70e108d3bf994a30d56fb.jpg"/>
		</div>
		<span class="close-wrap close-win">×</span>
		<div class="clear">

		</div>
		<div class="wrap-btn">
			<span class="close-btn close-win">取消</span>
			<span class="next-btn close-win">确认</span>
		</div>
	</div>
</div>

<script src="../../static/home/js/jquery-1.9.1.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../static/home/js/js.js" type="text/javascript" charset="utf-8"></script>
<script src="../../static/home/js/echarts.common.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../static/home/js/dateRange.js" type="text/javascript" charset="utf-8"></script>
<script src="../../static/home/js/monthPicker.js" type="text/javascript" charset="utf-8"></script>
<script src="../../static/home/js/img_yasuo.js" type="text/javascript" charset="utf-8"></script>


<script type="text/javascript">
	var Ptid = "0";   //获取每级id
	var Level = "0";   //获取级别
	var this_data = '';	//获取菜单ID
	var datall = []; //保存大分类请求数据
	var ajaxurl = "__publicPath__/home/commtype/addajax";		//分类请求地址
	$("#forms form .bor4 ul li").click(function(){
		this_data = $(this).attr('data-type');
		ajaxurl = "__publicPath__/home/commtype/addajax?id=" + this_data;	
	})
	$(".bor4").unbind('click').bind('click',function(){
		if(this_data == ''){
			// prompt('请选择上级菜单',0);
		} else{
			$(".bor7 ul li").remove()
			//alert('-')
			var	are = '';
			$.ajax({
				type:"get",
				url:ajaxurl,
				data: '',
				dataType: "json",
				success: function(data){
					datall = data;
					for (var i = 0; i < data.length; i++){      //一级分类
						are += "<li data-type="+data[i].ptid+">"+data[i].name+"</li>";
						Level = data[i].level
					}
					$(".bor6 ul").html('')
					$(".bor6 ul").append(are);
				},
				error:function(){
					alert('失败')
				}
			});
		}
		
	})
	$(document).ready(function(e) {
		var ue = UE.getEditor('container');
		$('input').lc_switch();
	});
	// IOS开关取值
	$('body').delegate('.recom', 'lcs-statuschange', function() {
		var status = ($(this).is(':checked')) ? 'checked' : 'unchecked';
		if (status == 'checked'){
			$(".recom").val(1)
		} else{
			$(".recom").val(0)
		}

	});

	$('body').delegate('.special_offer', 'lcs-statuschange', function() {
		var status = ($(this).is(':checked')) ? 'checked' : 'unchecked';
		if (status == 'checked'){
			$(".special_offer").val(1)
		} else{
			$(".special_offer").val(0)
		}

	});
	var i=0;
	$(".Addinput").click(function(){
		i++
		var html = "<p><input type='text' name='' id='' value='' class='inpa'/><input type='text' name='' id='' value='' class='inpb'/><input type='text' name='' id='' value='' class='inpc'/><input type='text' name='' id='' value='' class='inpd'/><input type='text' name='' id='' value='' class='inpe'/><i></i></p>"
		$(".addinput").append(html);
	})

	$(document).on("click", ".addinput p i", function(){
		$(this).parent().remove()
	});


	var datas = new Array();      //创建数组
	datas[0] =""; 				  //赋值
	$(".subbtn").click(function(){
		$("#caidan").prop('value','')
		var q1 = '.inpa';
		var q2 = '.inpb';
		var q3 = '.inpc';
		var q4 = '.inpd';
		var q5 = '.inpe';
		for (var i = 0; i < $(".addinput p").length; i++) {
			if ($(".addinput p").eq(i).find('input').val() !== ''){
				datas[i] = $(".addinput p").eq(i).find(q1).val()+"/*max*/"
				datas[i] += $(".addinput p").eq(i).find(q2).val()+"/*max*/"
				datas[i] += $(".addinput p").eq(i).find(q3).val()+"/*max*/"
				datas[i] += $(".addinput p").eq(i).find(q4).val()+"/*max*/"
				datas[i] += $(".addinput p").eq(i).find(q5).val()

			} else{
				alert('空')
			}

		}
		var dataarr = datas.join('/*/-/')
		$("#caidan").prop('value',datas)
		// 使用完数组再次清空数组
		for (var i = 0; i < datas.length; i++) {
			datas.splice(0,9999)
		}
	})

	var Li;  				//一级索引
	var towLi;				//二级索引
	//二级分类
	$(document).on("click", ".bor6 ul li", function (){
		let data = datall
		// event.stopPropagation();
		$(".bor7 ul li").remove()
		$(".bor7 span").text('请选择')
		Li = $(this).index()
		var	are = '';
		console.log(data);
		for (towLi = 0; towLi < data[Li].sub.length; towLi++) {   //二级菜单
			are += "<li data-type="+data[Li].sub[towLi].ptid+">"+data[Li].sub[towLi].name+"</li>"
			Level = data[Li].sub[towLi].level
		}
		$(".bor7 ul").html('')
		$(".bor7 ul").append(are)
	})
	$(".subbtn").click(function(){
		if (!regulars('','name','商品名','') || !regulars('','stock','库存','')) {
			return false
		}
		if ($('#forms input[type="file"]').val() == '') {
			prompt('请添加图片',0)
			return false
		}
		$("#menu").val();
		$("#imgurl").val('');
		if ($(".bor6 span").text() != "请选择"){
			Ptid = $(".bor6 span").attr('data-type')
			if ($(".bor7 span").text() != "请选择"){
				Ptid = $(".bor7 span").attr('data-type')
			}
		} else{
			prompt('请选择分类',0)
			return false
		}
		console.log("级别："+Ptid+" 级数："+Level)
		var arrse = arr.join('_)(_')
		$("#menu").val(Ptid)
	})

</script>
{/block}

